#include "linkedlistelementtest.h"

bool LinkedListElementTest::constructorTest() {
    LinkedListElement<double> *testElement = new LinkedListElement<double>(*(new double(2.236194)), 0);
    assert(testElement->element!=0);
    assert(testElement->next==0);
    assert(*(testElement->element)==2.236194);
    assert((testElement->back)==0);
    testElement->deleteAll();
    return true;
}

bool LinkedListElementTest::run() {
    short count=0;

    if (!LinkedListElementTest::constructorTest())
        std::cout << "ERROR " << ++count << " LinkedListElementTest::constructorTest() faild!" << std::endl;
    if (!LinkedListElementTest::constructorWithValueTest())
        std::cout << "ERROR " << ++count << " LinkedListElementTest::constructorWithValueTest() faild!" << std::endl;

    return count==0;
}

bool LinkedListElementTest::constructorWithValueTest() {
    LinkedListElement<double> *testElement2 = new LinkedListElement<double>(*(new double(10.2)),0);
    LinkedListElement<double> *testElement3 = new LinkedListElement<double>(*(new double(10.3)),testElement2);
    LinkedListElement<double> *testElement = new LinkedListElement<double>(*(new double(2.212194)),testElement2,testElement3);
    assert(testElement->element!=0);
    assert(testElement->next==testElement3);
    assert(*(testElement->element)==2.212194);
    assert(*(testElement->next->element)==10.3);
    assert(*(testElement->back->element)==10.2);
    testElement->deleteAll();
    testElement2->deleteAll();
    testElement3->deleteAll();
    return true;
}
